package com.nd.controller.admin;

import com.nd.pojo.bo.ConfigExpressBo;
import com.nd.pojo.bo.ConfigMallBo;
import com.nd.pojo.vo.BaseRespVo;
import com.nd.pojo.vo.ConfigExpressVo;
import com.nd.pojo.vo.ConfigOrderVo;
import com.nd.pojo.vo.ConfigWxVo;
import com.nd.service.ConfigurationManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author : PengFei Zhang
 * @Data :2021/6/6  9:46
 * @Description :
 */
//配置管理 zpf
@RestController
@RequestMapping("admin")
public class ConfigurationManagementController {

    @Autowired
    ConfigurationManagementService configurationManagementService;

    //商场配置
    @RequestMapping(value = "config/mall", method = RequestMethod.GET)
    public BaseRespVo ConfigMallGet() {
        ConfigMallBo configMallBo1 = configurationManagementService.selectConfigMall();
        return BaseRespVo.ok(configMallBo1);
    }

    @RequestMapping(value = "config/mall", method = RequestMethod.POST)
    public BaseRespVo ConfigMallPost(@RequestBody ConfigMallBo configMallBo) {
        configurationManagementService.updateConfigMall(configMallBo);
        return BaseRespVo.ok();
    }

    //运费配置
    @RequestMapping(value = "config/express", method = RequestMethod.GET)
    public BaseRespVo ConfigExpressGet() {
        ConfigExpressVo configExpressVo = configurationManagementService.selectConfigExpress();
        return BaseRespVo.ok(configExpressVo);
    }

    @RequestMapping(value = "config/express", method = RequestMethod.POST)
    public BaseRespVo ConfigExpressPost(@RequestBody ConfigExpressBo configExpressBo) {
        configurationManagementService.updateConfigExpress(configExpressBo);
        return BaseRespVo.ok();
    }

    //订单配置
    @RequestMapping(value = "config/order", method = RequestMethod.GET)
    public BaseRespVo ConfigOrederGet() {
        ConfigOrderVo configOreder = configurationManagementService.selectConfigOreder();
        return BaseRespVo.ok(configOreder);
    }

    @RequestMapping(value = "config/order", method = RequestMethod.POST)
    public BaseRespVo ConfigOrederPost(@RequestBody ConfigOrderVo configOrderVo) {
        configurationManagementService.updateConfigOreder(configOrderVo);
        return BaseRespVo.ok();
    }

    //小程序配置
    @RequestMapping(value = "config/wx", method = RequestMethod.GET)
    public BaseRespVo ConfigWxGet() {
        ConfigWxVo configWxVo = configurationManagementService.selectConfigWx();
        return BaseRespVo.ok(configWxVo);
    }
    @RequestMapping(value = "config/wx", method = RequestMethod.POST)
    public BaseRespVo  ConfigWxPost(@RequestBody ConfigWxVo configWxVo) {
        configurationManagementService.updateConfigWx(configWxVo);
        return BaseRespVo.ok();
    }

}
